﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace RVBike
{
    /// <summary>
    /// Interaction logic for WelcomePage.xaml
    /// </summary>
    public partial class WelcomePage : UserControl, ISwitchable
    {
        private System.Windows.Forms.Timer _refreshTimer;
        private int _count;

        public WelcomePage()
        {
            InitializeComponent();

            _count = 0;
            _refreshTimer = new System.Windows.Forms.Timer();
            _refreshTimer.Enabled = true;
            _refreshTimer.Interval = 33;
            _refreshTimer.Tick += new System.EventHandler(Refresh);

            DummyStart.Content = MultiLanguage.Instance().Translate("press_any_key");
        }

        private void Refresh(object sender, System.EventArgs e)
        {
            ++_count;
            if (_count < 15 )
            {
                DummyStart.Opacity = 0.03 * _count;
            }
            else
            {
                DummyStart.Opacity = 0.03 * (33 - _count);
            }

            if (_count == 33) _count = 0;
        }

        private void SwitchToMainPage()
        {
            RVSwitcher.Switch(new MainPage());
        }

        private void OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            SwitchToMainPage();
        }

        private void OnKeyUp(object sender, KeyEventArgs e)
        {
            SwitchToMainPage();
        }

        #region ISwitchable Members
        public void UtilizeState(object state)
        {
            throw new NotImplementedException();
        }

        public void WindowLocationChanged(double x, double y)
        {
        }
        #endregion
    }
}
